<!DOCTYPE html>
<html>
<head lang="en">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/>
    <link rel="shortcut icon" href="img/smlogo.png" type="image/x-icon">
    <meta charset="UTF-8">
    <title>Pulu</title>
    <link rel="stylesheet" href="css/textareapage.css"/>
    <link rel="stylesheet" href="css/index2.css"/>
    <style>
        .cmnt_fixed.callback{
            display:block;
            z-index:200;
        }
        .cmnt_fixed .cmnt_border{padding:8px 10px;}
        .cmnt_fixed .cmnt_textarea{height:auto;}
        .cmnt_fixed>p{
            padding:8px 10px;
            font-size: 12px;
            /*color:#808393;*/
            color:#b92b27;
        }
        .cmnt_fixed .cmnt_border {
            padding: 8px 10px;
            margin: 0 8px;
            border: 1px solid #dfdfdf;
        }
        .errorword{display:none;}

        #waitplace{
            display:none;
            width: 100%;
            z-index: 1000;
            left: 0;
            right: 0;
            position: fixed;
            top: 45%;
        }
        #waitplace>div {
            width: 80px;
            max-width: 240px;
            height: 80px;
            background: rgba(53,53,53,0.75);
            overflow: hidden;
            border-radius: 4px;
            margin: auto;
        }
        #waitplace div.lf{
            width:100%;
            height:100%;
            line-height:80px;
            text-align: center;
        }
        #waitplace>div>div:first-child>img {
            width: 44px;
            height: 44px;
            -webkit-animation: circle 1s infinite linear;
        }
        @-webkit-keyframes circle{
            0%{ transform:rotate(0deg); }
            100%{ transform:rotate(-360deg); }
        }

        #successNote{
            display:none;
            position:fixed;
            max-width:1000px;
            width:100%;
            height:100%;
            margin:0 auto;
            z-index: 999;
            background:rgba(0,0,0,0.75);
        }
        #successNote>div{
            position:relative;
            width:100%;
            height:100%;
        }
        #successNote>div>.lf{
            position:absolute;
            width:100%;
            max-width:300px;
            top:50%;
            left:50%;
            transform: translate(-50%,-50%);
            -webkit-transform: translate(-50%,-50%);
            -moz-transform: translate(-50%,-50%);
            -o-transform: translate(-50%,-50%);
            -ms-transform: translate(-50%,-50%);
            background: #fff;
            border-radius: 2px;
            text-align: center;
            display: block;
            padding: 12px 0;
            color: #333;
            line-height: 1.4;
            font-size: 15px;
            font-weight: initial;
        }
        #commentinput::-webkit-input-placeholder{color:#BF8075;}
        #commentinput:-moz-placeholder{color:#BF8075;}
        #commentinput:-ms-input-placeholder{color:#BF8075;}
    </style>
</head>
<body class=" experiment-lookup_bar-on gating-feed_switcher_bar-on mweb  gating-new_mweb_header_logged_out-off" style="background: #fff">
<!--评论输入区-->
<div class="cmnt_fixed callback">
    <div class="th_td">
        <a class="cmnt_cancel" id="cancelbtn">取消</a>
        <a class="cmnt_smt none_cmnt" id="sendcommentbtn">确定</a>
    </div>
    <div class="cmnt_border" style="margin-bottom:20px;">
        <textarea class="cmnt_textarea" id="desinput" placeholder="这一刻的想法..."></textarea>
    </div>
    <div class="cmnt_border">
        <input type="text" class="cmnt_textarea" id="commentinput" placeholder="请添加网址链接"/>
    </div>
    <p>
        <span class="noticword"><i>*</i>我们会根据网址获取相关内容，作为发布的资讯标题</span>
        <span class="errorword"></span>
    </p>
</div>
<!--waiting-->
<div id="waitplace">
    <div>
        <div class="lf">
            <img src="img/aoy.png">
        </div>
    </div>
</div>
<!--提醒-->
<div id="successNote">
    <div>
        <div class="lf">
            分享成功
        </div>
    </div>
</div>
<script src="js/jquery-1.11.3.js"></script>
<script src="js/jquery.cookie.js"></script>
<script src="js/tohref.js"></script>
<script src="ftnjs/urlnote.js"></script>
<!--插入表情及按钮操作-->
<script>
    //点击返回
    $("#cancelbtn").click(function(){history.go(-1)});
    //输入判断
    $('#commentinput').bind('input propertychange', function() {
        $(".noticword").css("display","block");
        $(".errorword").css("display","none");
        $("#sendcommentbtn").attr("class","cmnt_smt none_cmnt");
        var textval=$('#commentinput').val();
        var urlregex = new RegExp("^((http|ftp|https)://)(([a-zA-Z0-9\._-]+\.[a-zA-Z]{2,6})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(:[0-9]{1,4})*(/[a-zA-Z0-9\&%_\./-~-]*)?");
        if(urlregex.test(textval)){
            console.log("输入网址");
            if(/pulu\.com/.test(textval)){
                console.log("铺路网址");
                $(".noticword").css("display","none");
                $(".errorword").html("不能复制pulu内部网址");
                $(".errorword").css("display","block");
            }
            else{
                $("#sendcommentbtn").attr("class","cmnt_smt");
            }
        }
    });
    //点击发布资讯
    $("#sendcommentbtn").click(function(i){
        if(i.target.className=="cmnt_smt"){
            var textval=$('#commentinput').val();
            if(/^(www)\./.test(textval)){
                console.log("网址不完整");
                $(".noticword").css("display","none");
                $(".errorword").html("请复制正确的网址");
                $(".errorword").css("display","block");
            }
            else{
                console.log("正确");
                var des=$("#desinput").val().trim();
                $("#waitplace").css("display","block");
                $.ajax({
                    type:"post",
                    url:shareoutnewsurl,
                    data:{"url":textval,"userId": $.cookie("MYID"),"des":des},
                    success:function(d){
//                        location.reload();
                        if(d.Code=="FALSE"){
                            $("#waitplace").css("display","none");
                            $(".noticword").css("display","none");
                            $(".errorword").html("当前链接发布失败！");
                            $(".errorword").css("display","block");
                            $('#commentinput').val("");
                        }
                        else{
                            $("#waitplace").css("display","none");
                            $("#successNote").css("display","block");
                            setTimeout(function(){
                                //清除跳转页面参数
                                $.cookie("puluShowPage","");
                                $.cookie("puluscrollTop","");
                                $.cookie("pulucurrentIndex","");
                                location.href="subscribe.html";
                            },500);
                        }
                    },
                    error:function(d){
                        $("#waitplace").css("display","none");
                        $(".noticword").css("display","none");
                        $(".errorword").html("请复制正确的网址");
                        $(".errorword").css("display","block");
                        $('#commentinput').val("");
                    }
                })
            }
        }else{
            console.log("网址错误");
            $(".noticword").css("display","none");
            if(/pulu\.com/.test($('#commentinput').val())){
                $(".errorword").html("不能复制pulu内部网址");
            }else{
                $(".errorword").html("请复制正确的网址");
            }
            $(".errorword").css("display","block");
        }
    });
</script>
</body>
</html>